package cn.ygh.bbo.generator;

import cn.ygh.bbo.common.entity.server.Sys;
import cn.ygh.bbo.generator.config.Config;
import cn.ygh.bbo.generator.entity.Clazz;
import cn.ygh.bbo.generator.service.DbService;
import cn.ygh.bbo.generator.service.FreemarkerService;
import freemarker.template.TemplateException;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @author ygh
 * @Type Main.java
 * @Desc
 * @date 2019/10/9
 * @Version V2.0
 */
public class Main {
    public static void main(String[] args) throws IOException, SQLException, TemplateException {
        //配置信息初始化
        Config.init();
        //数据库结构读取
        DbService dbService=new DbService();
        List<Clazz> clazzList=dbService.getClazzs();
        long start=System.currentTimeMillis();
        System.out.println("生成中请稍等");
        //代码生成
        FreemarkerService freemarkerService = FreemarkerService.getInstance();
        for (Clazz clazz:clazzList){
            freemarkerService.generate(clazz);
        }
        long end=System.currentTimeMillis();
        System.out.println("生成结束 "+(end-start)+"ms");
    }
}
